package com.nononsenseapps.feeder.processor.interceptor

import com.nononsenseapps.feeder.core.R
import com.nononsenseapps.feeder.db.entity.FeedItem
import com.nononsenseapps.feeder.processor.Interceptor

class FullPageCheckerInterceptor :Interceptor{
    override fun intercept(chain: Interceptor.Chain): FeedItem {
       val feed=chain.getFeed()
       val feedItem=chain.getFeedItem()
        if(feed.fullTextSync&&feedItem.fullTextSync ) {
            if(feedItem.plainSnippet.isEmpty()&&feedItem.description.isNotEmpty()) {
                feedItem.plainSnippet = chain.getProcessContext().context.getString(R.string.full_page_loading)
                chain.getProcessContext().modifyFlag = true
            }
            return feedItem
        }
       return chain.proceed(feed, feedItem)
    }
}